<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery-1.12.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/axios-0.18.0.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/antd.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="css/antd.css" />
		<script src="js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
		
		<style type="text/css">
			tr{
				height: 50px;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<div style="50px;font-size: 20px;line-height: 50px;padding-left: 50px;">
				添加公告
			</div>
			<table border="0px" style="margin: auto;width: 80%;margin-top: 50px;">
				<tr>
					<td style="width: 15%;text-align: right;"><span style="color: red;">*</span>公告主题：&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<td style="width: 70%;"><input type="text" name="" id="gname"  style="width: 100%;" /></td>
				</tr>
				<tr>
					<td style="width: 15%;text-align: right;">文章内容：&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<td style="width: 70%;"><textarea id="content" style="width: 100%; height: 150px;" placeholder="说点什么...至少十个字符"></textarea></td>
				</tr>
				<tr>
					<td style="width: 15%;text-align: right;"></td>
					<td style="width: 70%;">
						<span style="background: blue;color: white;border-radius: 5px;text-align: center;width: 70px;height: 30px;line-height: 30px;" class="glyphicon glyphicon-picture" aria-hidden="true" @click="insert()">保存</span>
						<span style="background: #BFBFBF;border-radius: 5px;text-align: center;width: 65px;height: 30px;line-height: 30px;display: inline-block;" onclick="window.location.href='post.html'">取消</span>
					</td>
				</tr>
				
			</table>
			
		</div>
	</body>
</html>
<script type="text/javascript">
	var vm=new Vue({
		el:"#app",
		data:{},
		beforeMount:{
			
			
			
		},
		methods:{
			insert:function(){
				if(sessionStorage.getItem("superid")==null){
					alert("请登录！！！")
					window.location.href="login.html";
				}
				if($("#gname").val()==""){
					alert("公告主题不能为空！！！")
				}else{
				axios({
					method:"POST",
					url:"http://localhost:8080/Blogs_demo/post/postInsert",
					data:{
						"gname":$("#gname").val(),
						"content":$("#content").val(),
						"author":sessionStorage.getItem("supername"),
						"superid":sessionStorage.getItem("superid"),
					},
					
				}).then(res=>{
					console.log(res.data);
					window.location.href="post.html"
				}).catch(err=>{
					
					alert("服务出错了!!")
				})
				}
			}
			
			
		}
		
		
	})
</script>
